import time
import pytest
from playwright.sync_api import sync_playwright, expect



@pytest.fixture()
def page():
    # 初始化框架并启动后台
    with sync_playwright() as p:
        # 打开浏览器p.firefox.launch
        # 不要无头模式headless=False
        browser = p.firefox.launch(headless=False)
        # 打开新的页面
        page = browser.new_page()
        yield page
        page.close()


class Test_jiuxian():

    def test_jiuxian_01(self,page):
            #访问目标网页
            page.goto('https://mail.163.com/')
            time.sleep(5)
            #开始编写脚本
            #进入框架
            # 输入账号密码
            frame=page.frame_locator('xpath = /html/body/div[3]/div[3]/div[1]/div/div[3]/div[1]/div[2]/iframe')
            frame.locator('input[name="email"]').fill('13381144084')
            frame.locator('input[name="password"]').fill('grq200566++')
            #点击登录按钮
            frame.locator('#dologin').click()
            time.sleep(8)